package org.budo.taobao.factory;

import org.springframework.beans.factory.FactoryBean;

import com.taobao.api.DefaultTaobaoClient;
import com.taobao.api.TaobaoClient;

import lombok.Getter;
import lombok.Setter;

/**
 * @author limingwei
 */
@Getter
@Setter
public class TaobaoClientFactoryBean implements FactoryBean<TaobaoClient> {
    private String serverUrl = "http://gw.api.taobao.com/router/rest";

    private String appKey;

    private String appSecret;

    @Override
    public TaobaoClient getObject() throws Exception {
        return new DefaultTaobaoClient(this.getServerUrl(), this.getAppKey(), this.getAppSecret());
    }

    @Override
    public Class<?> getObjectType() {
        return TaobaoClient.class;
    }

    @Override
    public boolean isSingleton() {
        return true;
    }
}